package com.rabbitmq.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author yinxing
 * @date 2022-08-29
 */
public class ConnectionUtils {

    private final static String HOST = "192.168.72.128";

    private final static String USERNAME = "guest";

    private final static String PASSWORD = "guest";

    private final static int PORT = 5672;

    public static Channel getChannel() {
        try {
            //创建连接工厂
            ConnectionFactory factory =new ConnectionFactory();
            factory.setHost(HOST);
            factory.setUsername(USERNAME);
            factory.setPassword(PASSWORD);
            factory.setPort(PORT);
            //创建连接
            Connection connection = factory.newConnection();
            //创建信道
            Channel channel = connection.createChannel();
            return channel;
        }catch (Exception e){

        }
        return null;
    }

}
